@extends('admin.layout.main')
@section("content")
    <form class="layui-form" action="/admin/task" method="post">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>任务新增</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">任务名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" autocomplete="off" placeholder="请输入标题" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">任务分类</label>
            <div class="layui-input-inline">
                <select name="type_id">
                    <option value="">请选择一种任务分类</option>
                    <optgroup label="员工">
                        @foreach($types as $type)
                            <option value="{{$type->id}}">{{$type->name}}</option>
                        @endforeach
                    </optgroup>
                </select>
            </div>
            <button type="button" class="layui-btn" id="sb" onclick="create()">添加分类</button>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">任务具体内容</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" name="task_content" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">分配用户</label>
                <div class="layui-input-inline">
                    <select name="user_id">
                        <option value="">请选择分配的员工</option>
                        <optgroup label="员工">
                            @foreach($users as $user)
                                <option value="{{$user->id}}">{{$user->name}}</option>
                            @endforeach
                        </optgroup>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">时间区间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="datetime" id="test16" placeholder="开始 到 结束">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script>
        layui.use(['upload','layer'], function() {
            var $ = layui.jquery
                , upload = layui.upload;
            var layer = layui.layer;

            $('#sb').on('click', function () {
                layer.open({
                    type: 2  //1普通公告 2
                    , title: ["大家好", 'font-size:18px;text-align:center'] //False不显示标题栏
                    , area: ['730px', '560px']
                    , shade: 0.8
                    , maxmin: true
                    , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                    , btnAlign: 'c'
                    , zIndex: layer.zIndex //重点1
                    , moveType: 0 //拖拽模式，0或者1
                    , content: 'http://agonicrm.com/admin/task_type/create' //调用的函数fliters
                    , success: function (layero) {
                        var btn = layero.find('.layui-layer-btn');
                        btn.find('.layui-layer-btn0').attr({
                            href: '/'
                            , target: '_self'
                        });
                        //filter()
                    }
                });
            });
        });
    </script>
@endsection
